<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>会员列表</title>

    <meta name="keywords" content="">
    <meta name="description" content="">

    <!--[if lt IE 8]>
    <script>
        alert('H+已不支持IE6-8，请使用谷歌、火狐等浏览器\n或360、QQ等国产浏览器的极速模式浏览本页面！');
    </script>
    <![endif]-->

    <link href="/static/admin/public/css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="/static/admin/public/css/font-awesome.min.css?v=4.3.0" rel="stylesheet">
    <link href="/static/admin/public/css/animate.min.css" rel="stylesheet">
    <link href="/static/toastr/toastr.min.css" rel="stylesheet"></link>
    <link href="/static/admin/public/css/style.min.css?v=3.2.0" rel="stylesheet">
    <link href="/static/admin/plugins/jsTree/css/style.min.css" rel="stylesheet">
</head>

<body class="fixed-sidebar full-height-layout gray-bg">
<div class="wrapper wrapper-content animated fadeInRight" id="contentList">
    <div class="ibox float-e-margins" >

        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5 class="pull-left">会员列表</h5>
            </div>
            <div class="ibox-content">
                <div class="row form-horizontal m-t">
                    <div class="col-sm-3 ">
                        <div class="form-group"><label class="col-sm-4 control-label">注册手机号：</label>
                            <div class="col-sm-8"><input v-model="phone"  name="name"  type="text" class="form-control"></div>
                        </div>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group"><label class="col-sm-3 control-label">开始时间：</label>
                            <div class="col-sm-9"><input readonly id="company_time" v-model="start_time"  name="name"  type="text" class="form-control"></div>
                        </div>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group"><label class="col-sm-3 control-label">结束时间：</label>
                            <div class="col-sm-9"><input readonly id="company_time2" v-model="end_time" name="name"  type="text" class="form-control"></div>
                        </div>
                    </div>
                </div>
                <div class="row form-horizontal m-t">
                    <div class="col-sm-3 ">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">企业类型：</label>
                            <div class="col-sm-8">
                                <select v-model="memberCategory"  name="name"  type="text" class="form-control">
                                    <option value="-1">全部</option>
                                    <option value="1">货主企业</option>
                                    <option value="2">物流企业</option>
                                </select>
                            </div>

                        </div>
                    </div>
                    <div class="col-sm-3 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">状态：</label>
                            <div class="col-sm-9">
                                <select v-model="memberInfoStatus"  name="name"  type="text" class="form-control">
                                    <option value="-1">全部</option>
                                    <option value="0">未通过</option>
                                    <option value="1">已通过</option>
                                </select>
                            </div>

                        </div>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group">
                            <button type="button" class="btn btn-primary" @click="changeWhereGetList()">查询</button>
                        </div>
                    </div>

                </div>
                <table class="table">
                    <thead>
                    <tr>
                        <th>会员账号</th>
                        <th>公司名称</th>
                        <th>所述企业</th>
                        <th>资金</th>
<!--                        <th>归属地</th>-->
                        <th>联系人</th>
                        <th>职务</th>
                        <th>联系电话</th>
                        <th>固定电话</th>
                        <th>会员到期时间</th>
                        <th>创建时间</th>
                        <th>更新时间</th>
                        <th>是否显示首页</th>
                        <th>状态</th>
                        <th>操作</th>
<!--                        <th>状态显示</th>-->
                    </tr>
                    </thead>
                    <tbody>
                    <tr v-for="(item,index) in list">
                        <td>{{item.phone}}</td>
                        <td class="company_title">{{item.name}}</td>
                        <td>{{category_message[item.member_category-1]}}</td>
                        <td>{{item.fund}}</td>
<!--                        <td>{{item.address}}</td>-->
                        <td>{{item.contacts}}</td>
                        <td>{{item.position}}</td>
                        <td>{{item.mobile}}</td>
                        <td>{{item.landine_phone}}</td>
                        <td>{{item.member_time | formatDate}}</td>

                        <td>{{item.create_time | formatDate}}</td>
                        <td>{{item.create_time | formatDate}}</td>
                        <td >
                            <div role="group" aria-label="..." class="btn-group">
                                <button @click="setCommendFlag(item)" type="button" v-bind:class="[item.commend_flag==1?'btn-primary':'btn-danger']" class="btn btn-xs">
                                    {{item.commend_flag==1?'是':'否'}}
                                </button>
                            </div>
                        </td>

                        <td>
                            <div role="group" aria-label="..." class="btn-group">
                                <!--                                "[{'btn-success':item.status==1},{'btn-danger':item.status==0}]"-->
                                <button @click="changeStatus(item,1)" type="button" v-bind:class="[item.status==1?'btn-primary':'btn-danger']" class="btn btn-xs">
                                    {{item.status==1?'已通过':'未通过'}}
                                </button>
                            </div>
                        </td>
                        <td>
                            <div role="group" aria-label="..." class="btn-group">
                                <a v-bind:href="'/admin/member/detail/id/'+item.member_id" type="button" class="btn btn-warning btn-xs">查看详情</a>
                                <a v-if="item.member_category==1" v-bind:href="'/admin/member/myLogistics/id/'+item.member_id" type="button" class="btn btn-success btn-xs">我的服务商</a>
                                <a v-if="item.member_category==2" v-bind:href="'/admin/member/myConsignor/id/'+item.member_id" type="button" class="btn btn-success btn-xs">我的货主</a>
                                <a v-if="item.member_category==2" v-bind:href="'/admin/member/setMemberGrade/id/'+item.member_id" type="button" class="btn btn-primary btn-xs">会员设置</a>
                                <button @click="removeMember(item.member_id,index)" type="button" class="btn btn-danger btn-xs">注销</button>
                            </div>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="ibox-content text-center">
                <div class="btn-group">
                    <button type="button" class="btn btn-white" @click="pageNextList(-1)"><i class="fa fa-chevron-left"></i>
                    </button>

                    <button class="btn" v-bind:class="pageInfo.current_page==item?'btn-primary':'btn-white'" v-for="item in pageInfo.total" @click="changePage(item)">{{item}}</button>
                    <button type="button" class="btn btn-white">
                        <i class="fa fa-chevron-right" @click="pageNextList(1)">
                        </i>
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="/static/admin/public/js/jquery-2.1.1.min.js"></script>
<script src="/static/admin/public/js/bootstrap.min.js?v=3.4.0"></script>
<script src="/static/admin/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/static/admin/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/static/admin/plugins/layer/layer.min.js"></script>
<script type="text/javascript" src="/static/vue/vue.js"></script>

<!-- 自定义js -->
<script type="text/javascript" src="/static/util/axios.min.js"></script>
<script type="text/javascript" src="/static/admin/api/require.js"></script>
<script type="text/javascript" src="/static/admin/api/publicAjax.js"></script>

<!-- 第三方插件 -->
<script src="/static/toastr/toastr.min.js"></script>
<script src="/static/toastr/customToastr.js"></script>
<script src="/static/admin/plugins/jsTree/js/jstree.min.js"></script>
<!--时间组件-->
<script src="/static/util/laydate/laydate.js"></script>
<script>
    var vmAddChannel = new Vue({
        el:"#contentList",
        data:{
            'commend_message':['否','是'],
            "list":[],
            'current_page':1,
            'num':15,
            'category_message':['货主企业','物流企业'],
            "pageInfo":{},
            'start_time':'',
            'end_time':'',
            'phone':'',
            'memberCategory':-1,
            'memberInfoStatus':-1
        },
        methods:{
            pageNextList:function (num) {
                var el = this;
                var num = num;
                var pageNum = el.current_page+num
                if( pageNum < 1){
                    $.customToastr("error","已经是第一页啦");
                    return;
                }
                if(pageNum > el.pageInfo.total){
                    $.customToastr("error","已经是最后一页啦");
                    return;
                }
                el.current_page = pageNum

                el.getList();
            },
            changePage:function(num){
                var el = this
                el.current_page = num
                el.getList();
            },
            //条件更改无法从第一页查询，跳转方法
            changeWhereGetList:function(){
                var el = this
                el.current_page = 1
                el.getList()
            },
            getList:function () {
                let el = this
                var paging = {
                    'current_page':el.current_page,
                    'num':el.num
                }
                let postData = {
                    'paging':paging,
                    'phone':'',
                    'end_time':'',
                    'start_time':'',
                    'member_category':el.memberCategory,
                    'status':el.memberInfoStatus
                }
                if(el.phone!=''){
                    postData.phone = el.phone
                }
                if(el.end_time!=''&&el.start_time!=''){
                    postData.end_time = el.end_time
                    postData.start_time = el.start_time
                }


                AjaxPost(postData,'/admin/member/getList').then((response)=>{
                    var list = response.result.list
                    // if( response.result.list.length>0){
                    //     $.customToastr('success','查询完成')
                    // }else{
                    //     $.customToastr('warning','未查询到数据')
                    // }
                    el.list = list
                    el.pageInfo = response.result.pageInfo
                    console.log(el.list)
                })
            },
            removeMember:function (id,index) {
                var el = this;
                var postData = {
                    "id":member_id
                }

                layer.confirm('确定要删除吗？', {
                    btn: ['确定','取消'] //按钮
                }, function(index){
                    AjaxPost(postData,'/admin/member/removeMemberById').then((response)=>{
                        $.customToastr('success',response.message)
                        el.list.splice(index,1)
                    })
                });

            },

            changeStatus:function(item,status){
                var item = item
                console.log(item)
                if(item.status != null){
                    if(item.status == 1){
                        $.customToastr('warning','会员已经通过审核，请不要重复设置');
                        return
                    }
                     var where = {'member_id':item.member_id}
                     var data = {'status':status}
                     var postData = {
                         "where":where,
                         "data":data
                     }
                    AjaxPost(postData,'/admin/member/changeMemberInfoStatus').then((response)=>{
                        if(response.status == 1){
                            $.customToastr('success',response.message)
                            item.status = status
                        }
                    })
                }else{
                    $.customToastr('error','会员未认证，无法进行审核')
                }
            },
            setCommendFlag:function (item) {
                console.log(item)
                if(item.status==null){
                    return $.customToastr('warning','未认证，无法显示首页');
                }
                if(item.status == 0){
                    return $.customToastr('warning','认证未审核，无法显示首页');
                }
                item.commend_flag = 1-item.commend_flag
                var postData = {
                    'member_id':item.member_id,
                    'commend_flag':item.commend_flag
                }
                AjaxPost(postData,'/admin/member/setCommendFlag').then((response)=>{
                    $.customToastr('success',response.message)
                })
            }

        },
        filters: {
            formatDate: function (value) {
                if(!value || value == '0' || value == ''){
                    return value
                }
                let date = new Date(value*1000);
                let y = date.getFullYear();
                let MM = date.getMonth() + 1;
                MM = MM < 10 ? ('0' + MM) : MM;
                let d = date.getDate();
                d = d < 10 ? ('0' + d) : d;
                // let h = date.getHours();
                // h = h < 10 ? ('0' + h) : h;
                // let m = date.getMinutes();
                // m = m < 10 ? ('0' + m) : m;
                // let s = date.getSeconds();
                // s = s < 10 ? ('0' + s) : s;
                return y + '-' + MM + '-' + d;
            }
        },
        mounted(){
            var el = this
            this.getList();
            laydate.render({
                elem: '#company_time', //指定元素
                done: function (value,date,endDate) {
                    el.start_time =value
                }
            });
            laydate.render({
                elem: '#company_time2', //指定元素
                done: function (value,date,endDate) {
                    el.end_time =value
                }
            });
        }

    })
</script>

</body>

</html>